﻿#include "stdafx.h"
#include "XUIDragerIntParser.h"

#include "XBSTR.h"
#include "XString.h"
#include "StrUtil.h"
#include "Util.h"
#include "IXColorDraw.h"
#include "IXImageDraw.h"
#include "IXUIDrager.h"

#include "ParseHelper.h"

#if _IS_UI_DESIGNED_ENABLED_
CXUIDragerIntParser::CXUIDragerIntParser() : CXIntParserBase(&TIntCreateControl<IXUIDrager>)
{
    ;
}

CXUIDragerIntParser::~CXUIDragerIntParser()
{
    ;
}

// 填充属性
BOOL CXUIDragerIntParser::FillAttr(IN IXConfigNode* pNode, IN IXControl* pControl)
{
    BOOL bResult = m_ParentParser.FillAttr(pNode, pControl);
    if(!bResult)
        return bResult;

    IXUIDrager* pUIDrager = Util::QueryIntf<IXUIDrager>(pControl);
    if(pUIDrager == NULL)
        return FALSE;

    return bResult;
}

// 创建控件之后

BOOL TryToFindDragee(IXControl* pChild, LPARAM lParam)
{
    IXFrame* pFrame = dynamic_cast<IXFrame*>(pChild);
    if(pFrame != NULL)
    {
        IXUIDrager* pDrager = (IXUIDrager*)lParam;
        pDrager->put_Dragee(pFrame);
        return FALSE;
    }
    return TRUE;
}

BOOL CXUIDragerIntParser::PostCreate(IN IXConfigNode* pNode, IN IXControl* pControl)
{
    IXUIDrager* pDrager = dynamic_cast<IXUIDrager*>(pControl);
    XASSERT_ERROR(pDrager != NULL, _T("CXUIDragerIntParser::PostCreate Failed"));
    pControl->TransverseChilds(&TryToFindDragee, (LPARAM)pDrager);
    return TRUE;
}

#endif  // _IS_UI_DESIGNED_ENABLED_